# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=smtpmap
pkgver=0.8.234_BETA
pkgrel=5
groups=('blackarch' 'blackarch-fingerprint')
pkgdesc='Tool to identify the running smtp software on a given host.'
url='http://www.projectiwear.org/~plasmahh/software.html'
arch=('x86_64' 'aarch64')
license=('GPL')
depends=('libpcap')
source=("http://www.projectiwear.org/~plasmahh/${pkgname}-${pkgver/_/-}.tar.bz2"
        'gcc-3.4.patch'
        "$pkgname-64bit.patch")
sha512sums=('793c4e39e5b9eaecc7052d994e11834c08a2aa36826849fb4b99d128ea807ee208afb31cddd67261a70e5a196f1d5afca25d00db024faa05b8ba16b8d229440b'
            'c3cce6db810fa70450a39084c7841d4186bb7dae3198ca6cb38330009954a8bbc339e2e75adf87d1aeab9b24614fcdfd7353d1afef25b689c8966b2fcfb99953'
            '2c16bd0a8612a70dfa0f13c79a50c91356555fa318a223986c367f1fab94c2afee3fc7eadf8d94e446b054a0a4fab2693fd7190616862f6239ee979f0ef75bdb')

prepare() {
  cd "$pkgname-${pkgver/_/-}"

  patch -Np1 < "$srcdir/gcc-3.4.patch"
  patch -Np0 < "$srcdir/smtpmap-64bit.patch"

  sed -i "s|-O -Wall|$CFLAGS|g" makefile.conf
}

build() {
  cd "$pkgname-${pkgver/_/-}"

  ./configure --prefix=/usr

  make
}

package() {
  cd "$pkgname-${pkgver/_/-}"

  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 755 "src/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README TODO ChangeLog
  install -Dm 644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  cp share/* "$pkgdir/usr/share/$pkgname/"
}

